package com.example;

import com.example.bean.Product;
import com.example.bean.Student;
import com.example.container.XmlBeanFactory;

public class Main {
    public static void main(String[] args) {
        try {
            // 初始化IOC容器
            System.out.println("初始化IOC容器...");
            XmlBeanFactory beanFactory = new XmlBeanFactory("beans.xml");

            // 获取并输出Product bean
            Product product = (Product) beanFactory.getBean("product1");
            System.out.println("从IOC容器中获取的Product: " + product);

            // 获取并输出Student bean
            Student student = (Student) beanFactory.getBean("student1");
            System.out.println("从IOC容器中获取的Student: " + student);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
